@extends('teacher.base')
@section('main')
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
     <legend>材料管理</legend>
    </fieldset>
    @include('teacher.error')
    <form class="layui-form"  method="post" action="" enctype="multipart/form-data">
    {!! csrf_field() !!}
	  <div class="layui-form-item">
    <label class="layui-form-label">摘要</label>
    <div class="layui-input-block">
      <input type="text" name="title" lay-verify="required" placeholder="请输入题目名字" class="layui-input">
    </div>
  	</div>

    <div class="layui-form-item">
    <label class="layui-form-label">年级</label>
    <div class="layui-input-block">
      <select name="grade" lay-filter="aihao">
        @foreach($grades as $v)
        <option value="{{ $v->id }}">{{ $v->name }}</option>
        @endforeach
      </select>
    </div>
    </div>

	<div class="layui-form-item">
    <label class="layui-form-label">科目</label>
    <div class="layui-input-block">
      <select name="subject" lay-filter="aihao">
        @foreach($subjects as $v)
        <option value="{{ $v->id }}">{{ $v->name }}</option>
        @endforeach
      </select>
    </div>
    </div>

    <div class="layui-form-item">
    <label class="layui-form-label">材料</label>
    <div class="layui-input-block">
      <div id="editor">
        
      </div>
      <textarea id="text1" style="width:100%; height:200px;display: none;" name="content"></textarea>
    </div>
    </div>


  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
    </form>
<script type="text/javascript" src="{{asset('wangEditor.min.js')}}"></script>
<script type="text/javascript">
    var E = window.wangEditor
    var editor = new E('#editor')
    var $text1 = $('#text1')
    editor.customConfig.onchange = function (html) {
            // 监控变化，同步更新到 textarea
            $text1.val(html);
    }
    editor.create();
    $text1.val(editor.txt.html());
</script>
<script>

layui.use(['form', 'layer','element'], function(){
  var form = layui.form
  ,$ = layui.jquery
  ,element = layui.element
  ,layer = layui.layer;
	
form.on('radio(filter)', function(data){
  if(data.value==1){
	$('#chose_html').html(chose_html);
  $('#answer').show();
  }else if(data.value==2){
	$('#chose_html').html(chose_html2);
  $('#answer').hide();

  }else if(data.value==3){
  $('#chose_html').html(chose_html3);
  $('#answer').show();

  }
  console.log(data.elem); //得到radio原始DOM对象
  console.log(data.value); //被点击的radio的value值
});  


});
</script>

@endsection
